****Military Attitudes Survey
****Data collected by Qualtrics 1/17/2020 - 1/29/2020


*********************************
*Independent Variables***********
*********************************
*Note that tabular information for each recoded variable is used to comprise the demographic table in the Supplemental Materials and the sample demographic footnote in the paper.

* use "[working dir]\MilitaryData.dta"

***Main Experiment Variable
tab AFGroup

gen affgroup=.
replace affgroup=0 if AFGroup=="Control"
replace affgroup=1 if AFGroup=="IDTreat"
replace affgroup=2 if AFGroup=="NormTreat"
tab affgroup
label define affgroup 0 "Control" 1 "Identity Treatment" 2 "Norm Treatment"
label values affgroup affgroup
tab affgroup

gen idgroup=.
replace idgroup=0 if affgroup==0
replace idgroup=1 if affgroup==1
tab idgroup
label define idgroup 0 "Control" 1 "Identity Treatment" 
label values idgroup idgroup
tab idgroup

gen normgroup=.
replace normgroup=0 if affgroup==0
replace normgroup=1 if affgroup==2
tab normgroup
label define normgroup 0 "Control" 1 "Norm Treatment" 
label values normgroup normgroup
tab normgroup

*Q6 Are you now serving, have previously served, or have never served in the U.S. armed forces? Select all that apply.
*Now serving on active duty in the U.S. Air Force, Army, Coast Guard, Marine Corps, or Navy  (1) 
*Now serving in the National Guard or Reserve  (2) 
*Previously served on active duty in the U.S. Air Force, Army, Coast Guard, Marine Corps, or Navy  (3) 
*Previously served in the National Guard or Reserve  (4) 
*[dropped] I have never served in the U.S. military  (5) 
tab Q6

gen active=.
replace active=1 if Q6=="1"
replace active=1 if Q6=="1,2"
replace active=1 if Q6=="1,2,3"
replace active=1 if Q6=="1,2,3,4"
replace active=1 if Q6=="1,2,4"
replace active=1 if Q6=="1,3"
replace active=1 if Q6=="1,3,4"
replace active=1 if Q6=="1,4"
replace active=1 if Q6=="2"
replace active=1 if Q6=="2,3"
replace active=1 if Q6=="2,4"
replace active=0 if Q6=="3"
replace active=0 if Q6=="3,4"
replace active=0 if Q6=="4"
replace active=. if Q6=="5"
tab active


***Partisanship

*Q17 Generally speaking, do you think of yourself as a Republican, Democrat, or Independent?
*Republican  (1) 
*Democrat  (2) 
*Independent  (3) 
tab Q17
*Q18 Would you call yourself a strong Democrat or not a very strong Democrat?
*Strong Democrat  (1) 
*Not very strong Democrat  (2) 
tab Q18
*Q19 Would you call yourself a strong Republican or not a very strong Republican?
*Strong Republican  (1) 
*Not very strong Republican  (2) 
tab Q19
*Q20 Do you think of yourself as closer to the Republican Party or the Democratic Party?
*Closer to the Republican Party  (1) 
*Closer to the Democratic Party  (3) 
tab Q20
*Partisanship  scaled
gen party=.
replace party=1 if Q18==1
replace party=2 if Q18==2
replace party=3 if Q20==3
replace party=4 if Q20==1
replace party=5 if Q19==2
replace party=6 if Q19==1
tab party
*Partisanship, dichotomous
gen party2=.
replace party2=0 if party==1
replace party2=0 if party==2
replace party2=0 if party==3
replace party2=1 if party==4
replace party2=1 if party==5
replace party2=1 if party==6
tab party2
label define party2 0 "Democrat" 1 "Republican"
label values party2 party2
tab party2


*Ideology. 1 extremely liberal to 7 extremely conservative
tab Q5
gen ideo=Q5
tab ideo

*Q4 What is your gender?
*Male  (1) 
*Female  (2) 
*Other  (3) 
tab Q4
gen gender3=.
replace gender3=0 if Q4==1
replace gender3=1 if Q4==2
replace gender3=2 if Q4==3
tab gender3
label define gender3 0 "Male" 1 "Female" 2 "Other"
label values gender3 gender3
tab gender3

gen gender2=gender3
replace gender2=. if gender3==2
label define gender2 0 "Male" 1 "Female"
label values gender2 gender2
tab gender2

*Age Q84 What is your age?
tab Q84
gen newage=Q84
replace newage=. if Q84==99
tab newage
mean newage

*Education Q83 What is the highest level of education you have completed?
tab Q83
gen edu=Q83
tabstat edu, stats (p50 mean n)
tab edu

*Income Q85 What is your estimate of your annual household income (before taxes)?
tab Q85
gen income=Q85
tabstat income, stats (p50 mean n)


*Political knowledge
*Q79 How much of a majority is required for the U.S. Senate and House to override a presidential veto? 3 is correct
tab Q79
gen pk1=.
replace pk1=1 if Q79==3
replace pk1=0 if Q79==1
replace pk1=0 if Q79==2
replace pk1=0 if Q79==4
tab pk1

*Q80 What job or political office does Mitch McConnell now hold? 1 is correct
tab Q80
gen pk2=.
replace pk2=1 if Q80==1
replace pk2=0 if Q80==2
replace pk2=0 if Q80==3
replace pk2=0 if Q80==4
tab pk2

*Q81 Who is the Chief Justice of the U.S. Supreme Court? 2 is correct
tab Q81
gen pk3=.
replace pk3=1 if Q81==2
replace pk3=0 if Q81==1
replace pk3=0 if Q81==3
replace pk3=0 if Q81==4
tab pk3

*Q82 Which political party currently has the most Members in the U.S. House of Representatives? 2 is correct
tab Q82
gen pk4=.
replace pk4=1 if Q82==2
replace pk4=0 if Q82==1
tab pk4

*Additive PK index
gen pkadd= pk1 + pk2 + pk3 + pk4
tab pkadd


*Q13 What is your rank? If you are no longer serving in the military, mark your rank when you left the service.
*Enlisted (E-1 thru E-9)  (1) 
*Warrant Officer (W-1 thru W-5)  (2) 
*Officer (O-1 thru O-10)  (3) 
tab Q13
gen rank=Q13
tab rank
label define rank 1 "Enlisted" 2 "Warrant Officer" 3 "Officer"
label values rank rank
tab rank

gen rank2=.
replace rank2=0 if rank==1
replace rank2=1 if rank==2
replace rank2=1 if rank==3
tab rank2


*Race
*Q2 Are you Spanish, Hispanic, Latino, or none of these?
*Yes  (1) 
*None of these  (0) 
*Q3 Choose one or more races that you consider yourself to be. Check all that apply. 
*White  (1) 
*Black or African American  (2) 
*American Indian or Alaskan Native  (3) 
*Asian  (4) 
*Native Hawaiian or Pacific Islander  (5) 
*Other (please specify)  (6) 
tab Q2
tab Q3

gen race3=.
replace race3=0 if Q2==0 & Q3=="1"
replace race3=1 if Q2==0 & Q3=="2"
replace race3=2 if Q2==1 & Q3=="1"
replace race3=2 if Q2==1 & Q3=="2"
replace race3=2 if Q3=="1,2"
replace race3=2 if Q3=="1,2,3"
replace race3=2 if Q3=="1,2,3,4,5"
replace race3=2 if Q3=="1,2,3,5"
replace race3=2 if Q3=="1,2,5"
replace race3=2 if Q3=="1,3"
replace race3=2 if Q3=="1,4"
replace race3=2 if Q3=="1,4,5"
replace race3=2 if Q3=="1,5"
replace race3=2 if Q3=="2,3"
replace race3=2 if Q3=="2,4"
replace race3=2 if Q3=="2,5"
replace race3=2 if Q3=="3"
replace race3=2 if Q3=="3,6"
replace race3=2 if Q3=="4"
replace race3=2 if Q3=="5"
replace race3=2 if Q3=="6"
tab race3
label define race3 0 "Non-Hispanic White" 1 "Non-Hispanic Black" 2 "Other"
label values race3 race3
tab race3


********************************************************
**Main Text Analyses************************************
********************************************************

******Feeling Thermometer Table*************************

******Out-party feeling thermometer
*Feeling thermometer toward the Democratic Party
tab Q34_1
gen feeldem=Q34_1
gen repoutFT= feeldem if party2==1
tab repoutFT

*Feeling thermometer toward the Republican Party
tab Q34_2
gen feelrep=Q34_2
gen demoutFT= feelrep if party2==0
*Combined Out FT
egen outFT= rowmax(repoutFT demoutFT)
*No controls model
regress outFT i.affgroup, robust
*outreg2 using FTRegs_NoControls.doc, replace ctitle(Out FT) label 

******In-party feeling thermometer
gen deminFT=feeldem if party2==0
gen repinFT=feelrep if party2==1
egen inFT= rowmax(deminFT repinFT)
*No controls model
regress inFT i.affgroup, robust
*outreg2 using FTRegs_NoControls.doc, append ctitle(In FT) label 

******Distance between In and Out Party Feeling Thermometers
gen ftdist=inFT-outFT
tab ftdist
*No controls model
regress ftdist i.affgroup, robust
*outreg2 using FTRegs_NoControls.doc, append ctitle(FT Dist) label 



******Trait Rating Table

*Q35 Now we'd like to know what you think about Democrats. Below, is a list of words that some people might use to describe Democrats. For each item, please indicate how well you think it applies to them.
*1 not well at all, 5 extremely well
*Q36 same, but for Republicans
*American
tab Q35_1
gen traitAmericanD=Q35_1
tab Q36_1
gen traitAmericanR=Q36_1
egen traitAmerican= rowmax(traitAmericanD traitAmericanR)
*No controls model
regress traitAmerican i.affgroup, robust
*outreg2 using Traits_NoControls.doc, replace ctitle(American) label 


*Intelligent (2) 
tab Q35_2
gen traitIntelligentD=Q35_2
tab Q36_2
gen traitIntelligentR=Q36_2
*Honest (3) 
tab Q35_3
gen traitHonestD=Q35_3
tab Q36_3
gen traitHonestR=Q36_3
*Open-minded (4) 
tab Q35_4
gen traitOpenD=Q35_4
tab Q36_4
gen traitOpenR=Q36_4
*Generous (5) 
tab Q35_5
gen traitGenerousD=Q35_5
tab Q36_5
gen traitGenerousR=Q36_5
*Positive trait index (average)
gen postraitD = (traitAmericanD + traitIntelligentD + traitHonestD + traitOpenD  + traitGenerousD)/5
gen postraitR = (traitAmericanR + traitIntelligentR + traitHonestR + traitOpenR  + traitGenerousR)/5
egen postrait= rowmax(postraitD postraitR)
*No controls model
regress postrait i.affgroup, robust
*outreg2 using Traits_NoControls.doc, append ctitle(Positive Traits) label 


*Hypocritical (6) 
tab Q35_6
gen traitHypocritcalD=Q35_6
tab Q36_6
gen traitHypocritcalR=Q36_6
*Selfish (7) 
tab Q35_7
gen traitSelfishD=Q35_7
tab Q36_7
gen traitSelfishR=Q36_7
*Mean (8) 
tab Q35_8
gen traitMeanD=Q35_8
tab Q36_8
gen traitMeanR=Q36_8
*Negative trait index (average)
gen negtraitD = (traitHypocritcalD + traitSelfishD + traitMeanD)/3
tab negtraitD
gen negtraitR = (traitHypocritcalR + traitSelfishR + traitMeanR)/3
tab negtraitR
egen negtrait= rowmax(negtraitD negtraitR)
*No controls model
regress negtrait i.affgroup, robust
*outreg2 using Traits_NoControls.doc, append ctitle(Negative Traits) label 


*trait distance (average negative trait rating - average positive trait rating)
gen traitdist=negtrait-postrait
tab traitdist
regress traitdist i.affgroup, robust
*outreg2 using Traits_NoControls.doc, append ctitle(Trait Gap) label 




********Party Cue Experiment. Randomly assigned to 1 of 2 conditions; again, not tailored to respondent party
tab Trent2Group
gen cueexp=.
replace cueexp=0 if Trent2Group=="Trent2Dem"
replace cueexp=1 if Trent2Group=="Trent2Rep"
tab cueexp
label define cueexp 0 "Democratic Cue" 1 "Republican Cue"
label values cueexp cueexp
tab cueexp
*Q75 How difficult would it be for you to work closely in a military unit with someone who is a strong Democrat?
*Q77 How difficult would it be for you to work closely in a military unit with someone who is a strong Republican?
*1 not at all difficult to 5 extremely difficult
tab Q75
tab Q77
egen work= rowmax(Q75 Q77)
tab work
gen workout=.
replace workout=1 if cueexp==0 & party2==1
replace workout=1 if cueexp==1 & party2==0
replace workout=0 if cueexp==0 & party2==0
replace workout=0 if cueexp==1 & party2==1
tab workout

tabstat work if(affgroup==0), by(workout) stats(mean sem n)
regress work i.workout if(affgroup==0), robust
regress work i.workout if(affgroup==2), robust


regress work i.workout i.affgroup i.workout##i.affgroup, robust
*outreg2 using PartyCueExp.doc, replace ctitle(Work) label 
margins, dydx(i.workout) at(affgroup=(0(1)2)) vsquish
marginsplot, recast(scatter) scheme(s1mono) title("Difficulty of Working with Out-Party Relative to In-Party") yline(0,lpattern(dash)) xtitle("Experimental Condition", margin(medium)) ytitle("Effect on Difficulty of Working with Out-Party", margin(medium)) yscale(r(-.2 1)) xscale(r(-0.5 2.5))
*graph export WorkOut.pdf, replace



*Q76 How difficult would it be for you to serve under a military commander who is a strong Democrat?
*Q78 How difficult would it be for you to serve under a military commander who is a strong Republican?
*1 not at all difficult to 5 extremely difficult
tab Q76
tab Q78
egen servecomm= rowmax(Q76 Q78)
tab servecomm
gen serveout=.
replace serveout=1 if cueexp==0 & party2==1
replace serveout=1 if cueexp==1 & party2==0
replace serveout=0 if cueexp==0 & party2==0
replace serveout=0 if cueexp==1 & party2==1
tab serveout

tabstat servecomm if(affgroup==0), by(serveout) stats(mean sem n)
regress servecomm i.serveout if(affgroup==0), robust
regress servecomm i.serveout if(affgroup==2), robust


regress servecomm i.serveout i.affgroup i.serveout##i.affgroup, robust
*outreg2 using PartyCueExp.doc, append ctitle(Serve) label 
margins, dydx(i.serveout) at(affgroup=(0(1)2)) vsquish
marginsplot, recast(scatter) scheme(s1mono) title("Difficulty of Serving Under Out-Party Relative to In-Party") yline(0,lpattern(dash)) xtitle("Experimental Condition", margin(medium)) ytitle("Effect on Difficulty of Serving under Out-Party", margin(medium)) yscale(r(-.1 1)) xscale(r(-0.5 2.5))
*graph export ServeOut.pdf, replace


regress work i.workout i.affgroup i.workout##i.affgroup if(active==1), robust
*outreg2 using PartyCueExp.doc, append ctitle(Work Active) label 
regress servecomm i.serveout i.affgroup i.serveout##i.affgroup if(active==1), robust
*outreg2 using PartyCueExp.doc, append ctitle(Serve Active) label 



********************************************************
**Supplemental Materials Analses************************************
********************************************************

**********************
*****Apolitical Norm**
**********************
*Q86 How important is it for the U.S. military to stay out of politics?
*1 Not at all important to 5 extremely important
tab Q86
gen norm1=Q86
ologit norm1 i.affgroup, robust
*outreg2 using Norm_NoControls.doc, replace ctitle(Norm Q1) label 

*Q87 To what extent do you agree or disagree that the American people trust the U.S. military because it is above partisan politics?
*1 strongly disagree to 7 strongly agree
tab Q87
gen norm2=Q87
ologit norm2 i.affgroup, robust
*outreg2 using Norm_NoControls.doc, append ctitle(Norm Q2) label 

*Q88 To what extent do you agree or disagree that U.S. military service members should comply with the lawful orders of elected leaders regardless of whether those leaders are Democrats or Republicans?
*1 strongy disagree to 7 strongly agree
tab Q88
gen norm3=Q88
ologit norm3 i.affgroup, robust
*outreg2 using Norm_NoControls.doc, append ctitle(Norm Q3) label 

*Q89 To what extent do you agree or disagree that U.S. military service members have an obligation to the American people to stay out of politics?
*1 strongy disagree to 7 strongly agree
tab Q89
gen norm4=Q89
ologit norm4 i.affgroup, robust
*outreg2 using Norm_NoControls.doc, append ctitle(Norm Q4) label 


**Activation of Norm with Controls
ologit norm1 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Norm_Controls.doc, replace ctitle(Norm Q1) label 
ologit norm2 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Norm_Controls.doc, append ctitle(Norm Q2) label 
ologit norm3 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Norm_Controls.doc, append ctitle(Norm Q3) label 
ologit norm4 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Norm_Controls.doc, append ctitle(Norm Q4) label 


**********************
****National Identity*
**********************
*Q90 How strongly do you identify as an American?
*not at all strongly to extremely strongly
tab Q90
gen ident1=Q90
ologit ident1 i.affgroup, robust
*outreg2 using NatID_NoControls.doc, replace ctitle(ID Q1) label 
tabstat ident1, by(affgroup) stats(mean sem sd n)

*Q91 How important is being an American to you? 
*1 Not at all important to 5 extremely important
tab Q91
gen ident2=Q91
ologit ident2 i.affgroup, robust
*outreg2 using NatID_NoControls.doc, append ctitle(ID Q2) label 
tabstat ident2, by(affgroup) stats(mean sem sd n)

*Q92 When talking about Americans how often do you say "we" instead of "they"?
*1 Never to always 5
tab Q92
gen ident3=Q92
ologit ident3 i.affgroup, robust
*outreg2 using NatID_NoControls.doc, append ctitle(ID Q3) label 
tabstat ident3, by(affgroup) stats(mean sem sd n)

*ID index
gen idindex=(ident1 + ident2 + ident3)/3
tab idindex
regress idindex i.affgroup, robust
*outreg2 using NatID_NoControls.doc, append ctitle(Index) label 


**Activation of National Identity with Controls
ologit ident1 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using NatID_Controls.doc, replace ctitle(ID Q1) label 
ologit ident2 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using NatID_Controls.doc, append ctitle(ID Q2) label 
ologit ident3 i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using NatID_Controls.doc, append ctitle(ID Q3) label 
regress idindex i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using NatID_Controls.doc, append ctitle(Index) label 


*********************************
*Feeling Thermometers************
*********************************

*With controls models
regress outFT i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using FTRegs_Controls.doc, replace ctitle(Out FT) label 
regress inFT i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using FTRegs_Controls.doc, append ctitle(In FT) label 
regress ftdist i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using FTRegs_Controls.doc, append ctitle(FT Dist) label 


*********************************
*Trait Ratings************
*********************************
*With controls models
regress traitAmerican i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Traits_Controls.doc, replace ctitle(American) label 
regress postrait i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Traits_Controls.doc, append ctitle(Positive Traits) label 
regress negtrait i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Traits_Controls.doc, append ctitle(Negative Traits) label 
regress traitdist i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd, robust
*outreg2 using Traits_Controls.doc, append ctitle(Trait Diff) label 


************************************
*Party Cue experiment, OLogit with controls*
************************************
ologit work i.workout i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd i.workout##i.affgroup, robust
*outreg2 using CueExp_OlogitControls.doc, replace ctitle(Work) label 
ologit servecomm i.serveout i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd i.serveout##i.affgroup, robust
*outreg2 using CueExp_OlogitControls.doc, append ctitle(Serve) label 
ologit work i.workout i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd i.workout##i.affgroup if(active==1), robust 
*outreg2 using CueExp_OlogitControls.doc, append ctitle(Work Active) label 
ologit servecomm i.serveout i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd i.serveout##i.affgroup if(active==1), robust
*outreg2 using CueExp_OlogitControls.doc, append ctitle(Serve Active) label 



******************************************************
*Trump Feeling Thermometer and Impeachment************
******************************************************
******Feeling thermometer toward President Donald Trump
tab Q34_3
gen feeltrump=Q34_3
**Outparty regression (Dems)
*No controls model
regress feeltrump i.affgroup if(party2==0), robust
*outreg2 using FTTrump.doc, replace ctitle(Trump FT D) label 
**Inparty regression (Reps)
*No controls model
regress feeltrump i.affgroup if(party2==1), robust
*outreg2 using FTTrump.doc, append ctitle(Trump FT R) label 

regress feeltrump i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd if(party2==0), robust
*outreg2 using FTTrump.doc, append ctitle(Trump FT D) label 
regress feeltrump i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd if(party2==1), robust
*outreg2 using FTTrump.doc, append ctitle(Trump FT R) label 


****Trump Impeachment
*Q51 As you may know, the House of Representatives recently impeached President Trump. Which of the following comes closest to your opinion on this issue? 
*President Trump should NOT have been impeached  (1) 
*President Trump should have been impeached  (2) 
*Don't know/not sure  (3) 
tab Q51
gen impeach3=.
replace impeach3=0 if Q51==1
replace impeach3=1 if Q51==3
replace impeach3=2 if Q51==2
tab impeach3
ologit impeach3 i.affgroup i.party2 i.affgroup##i.party2, robust
*outreg2 using Impeach.doc, replace ctitle(No Controls) label 
ologit impeach3 i.affgroup i.party2 i.rank i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.party2, robust
*outreg2 using Impeach.doc, append ctitle(Controls) label 



******************************************************
*Observational style data, restrict to control group**
******************************************************
gen norm1st=(norm1-1)/4
tab norm1st
gen norm2st=(norm2-1)/6
tab norm2st
gen norm4st=(norm4-1)/6
tab norm4st

gen normavg=(norm1st + norm2st + norm4st)/3
tab normavg

regress outFT normavg i.rank i.active i.gender2 i.race3 newage income edu pkadd if(affgroup==0), robust
*outreg2 using NormPredict.doc, replace ctitle(Out FT) label 
regress postrait normavg i.rank i.active i.gender2 i.race3 newage income edu pkadd if(affgroup==0), robust
*outreg2 using NormPredict.doc, append ctitle(Pos Trait) label 


*********************************************************
*Moderation of main outcomes by Military Status and Rank*
*********************************************************

regress outFT i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.active, robust
*outreg2 using ModerationStatus.doc, replace ctitle(Out FT) label 
regress postrait i.affgroup i.rank i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.active, robust
*outreg2 using ModerationStatus.doc, append ctitle(Pos Trait) label 

regress outFT i.affgroup i.rank2 i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.rank2, robust
*outreg2 using ModerationRank.doc, replace ctitle(Out FT) label 
regress postrait i.affgroup i.rank2 i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.rank2, robust
*outreg2 using ModerationRank.doc, append ctitle(Pos Trait) label 




*********************************************************
*Moderation of main outcomes by Party
*******************************************************
regress outFT i.affgroup i.rank i.party2 i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.party2, robust
*outreg2 using ModerationParty.doc, replace ctitle(Out FT) label 
regress postrait i.affgroup i.rank i.party2 i.active i.gender2 i.race3 newage income edu pkadd i.affgroup##i.party2, robust
*outreg2 using ModerationParty.doc, append ctitle(Pos Trait) label 


*********************************************************
*Randomization Inference Tests*
*********************************************************
findit ritest
net describe ritest, from(https://raw.githubusercontent.com/simonheb/ritest/master/)

*OutFT
ritest normgroup _b[normgroup], reps(10000): regress outFT normgroup
ritest idgroup _b[idgroup], reps(10000): regress outFT idgroup
*InFT
ritest normgroup _b[normgroup], reps(10000): regress inFT normgroup
ritest idgroup _b[idgroup], reps(10000): regress inFT idgroup
*FTDist
ritest normgroup _b[normgroup], reps(10000): regress ftdist normgroup
ritest idgroup _b[idgroup], reps(10000): regress ftdist idgroup

*Trait American
ritest normgroup _b[normgroup], reps(10000): regress traitAmerican normgroup
ritest idgroup _b[idgroup], reps(10000): regress traitAmerican idgroup

*Positive trait
ritest normgroup _b[normgroup], reps(10000): regress postrait normgroup
ritest idgroup _b[idgroup], reps(10000): regress postrait idgroup

*Negative trait
ritest normgroup _b[normgroup], reps(10000): regress negtrait normgroup
ritest idgroup _b[idgroup], reps(10000): regress negtrait idgroup

*Trait difference
ritest normgroup _b[normgroup], reps(10000): regress traitdist normgroup
ritest idgroup _b[idgroup], reps(10000): regress traitdist idgroup




